home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
201-225
/
disk_222
/
plplot
/
src
/
source.zoo
/
pl3cut.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-05-15
|
844b
|
37 lines
/* Determines the point of intersection (cx,cy) between the line */
/* joining (sx1,sy1) to (sx2,sy2) and the line joining */
/* (su1,sv1) to (su2,sv2). */
#include "plplot.h"
void pl3cut(sx1,sy1,sx2,sy2,su1,sv1,su2,sv2,cx,cy)
int sx1, sy1, sx2, sy2, su1, sv1, su2, sv2, *cx, *cy;
{
int x21, y21, u21, v21, yv1, xu1, a, b;
x21 = sx2 - sx1;
y21 = sy2 - sy1;
u21 = su2 - su1;
v21 = sv2 - sv1;
yv1 = sy1 - sv1;
xu1 = sx1 - su1;
a = x21 * v21 - y21 * u21;
if (a == 0) {
if (sx2 < su2) {
*cx = sx2;
*cy = sy2;
}
else {
*cx = su2;
*cy = sv2;
}
return;
}
else {
b = yv1 * u21 - xu1 * v21;
*cx = sx1 + (b * x21 + a/2) / a;
*cy = sy1 + (b * y21 + a/2) / a;
}
}